home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2877 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: amaryllisp1.appsig.com!user
  2. From: larry_kearney@appsig.com (Lawrence Kearney)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Interesting declaration???
  5. Date: Wed, 24 Jan 1996 07:40:14 -0700
  6. Organization: Applied Signal Technology
  7. Message-ID: <larry_kearney-2401960740140001@amaryllisp1.appsig.com>
  8. References: <4e3on1$iir@masala.cc.uh.edu>
  9. NNTP-Posting-Host: amaryllisp1.appsig.com
  10.  
  11. > Hi there,
  12. >         I was going through some of the header files of Motif and found an
  13. > interesting declaration like this:
  14. > typedef enum{
  15. >                 NONE,
  16. >                 ONE,
  17. >                 TWO} TabelType;
  18. > #define TableType unsigned char
  19. > I haven't seen this kind of declartion before and I tried it after seeing this
  20. > and it worked.!! I was expecting the compiler to throw a flag. Why would
  21. > someone do this?? 
  22. > My best guess is that they are making sure the TableType gets only one
  23. > byte instead of four (On Unix).
  24. > TIA
  25. > Srini. 
  26.  
  27. If the preprocessor #define statement follows the typedef as you show, it
  28. shadows the latter as the C preprocessor is run first against the source
  29. file. This causes all instances of the string "TableType" (outside of
  30. quotes, of course), to be converted to the string "unsigned char". This
  31. means that a declaration of
  32.  
  33. TableType variable;
  34.  
  35. is converted to
  36.  
  37. unsigned char variable;
  38.  
  39. before it is actually passed into the compiler.
  40.  
  41. -- 
  42. Larry Kearney                   |   "You want fries with that?"
  43. Applied Signal Technology       |
  44. larry_kearney@appsig.com        |
  45.